<?php
    $strSel = 'selected="selected"';
    $chkSel = 'checked="checked"';
    $dispay = 'style="display:block"';
    
?>

<form action="<?= lang_url('transfers/search') ?>" method="GET" id="transfer_form" class='form_<?= $this->lang->mci_current() ?>'>

    <fieldset>

        <div class="legend"><?= lang('find_transfer') ?></div>

        <div class="control-group clearfix where">

            <label class="control-label home_control_label"><?= lang('departure') ?></label>

            <div class="controls clearfix">    

                <select class="form-control input-sm" name="dest_from"  data-id="dest_to" required>
                    <option value="" ><?= lang('please_select') ?></option>
                    <?php foreach ($destFrom as $dest): ?>
                            <option value="<?= $dest->ID ?>" <?php if ((isset($_GET['dest_from']) && ($dest->ID === $_GET['dest_from']))) echo $strSel; ?>><?= $dest->name ?></option>
                        <?php endforeach; ?>
                </select>


            </div>

        </div> <!-- / Dest From-->

        <div class="control-group clearfix where">

            <label class="control-label home_control_label"><?= lang('arrival') ?></label>

            <div class="controls clearfix">    

                <select class="form-control input-sm" name="dest_to" required>
                    <option value="" ><?= lang('please_select') ?></option>

                    <?php
                        if (isset($destTo))
                            foreach ($destTo as $dest):
                                ?>
                                <option value="<?= $dest->ID ?>" <?php if ((isset($_GET['dest_to']) && ($dest->ID === $_GET['dest_to']))) echo $strSel; ?>><?= $dest->name ?></option>
                            <?php endforeach; ?>
                </select>


            </div>

        </div> <!-- / Dest To-->

        <div class="control-group clearfix vertical2 when_cor">

            <label class="control-label home_control_label"><?= lang('date') ?></label>

            <div class="controls clearfix">

                <?php
                    $check_in = date('d.m.Y', strtotime("+0 day"));

                    if (isset($_GET['check_in']))
                        $check_in = $_GET['check_in'];

                    $check_out = date('d.m.Y', strtotime("+1 day"));

                    if (isset($_GET['check_out']))
                        $check_out = $_GET['check_out'];
                ?>

                <div class="pull-left">    

                    <input type="text" value="<?= $check_in ?>" name="check_in" id="check_in" class="checkinout">

                </div>

                <div class="pull-left hide" id="ret_transfer_controll" <?php if (isset($_GET['return_transfer'])) echo $dispay; ?>>  

                    <input type="text" value="<?= $check_out ?>" name="check_out" id="check_out" class="checkinout">

                </div>

            </div>

        </div> <!-- / destinations-->

        <div class="control-group clearfix what">

            <div class="controls clearfix">    

                <input type="checkbox" class="" value="1" name="return_transfer" id="return_transfer" <?php if (isset($_GET['return_transfer'])) echo $chkSel; ?>> <span><?= lang('book_a_return') ?>?</span>
            </div>

        </div> <!-- / destinations-->

        <div class="control-group clearfix vertical2 persons personaccomm">

            <label class="control-label home_control_label label_person_<?= $this->lang->mci_current() ?>"><?= lang('form.persons_title'); ?>?</label>

            <div class="controls clearfix">   

                <select name="nr_adults" id="nr_adults" class="input-small pull-left">

                    <?php
                        $sel_text = 'selected = "selected"';
                        $cnt = 19;

                        if (isset($_GET['nr_adults'])) {
                            $selected = $_GET['nr_adults'];
                        } else {
                            $selected = 1;
                        }

                        for ($index = 1; $index <= $cnt; $index++):
                            ?>

                            <option value = "<?= $index ?>" <?php if ($selected == $index) echo $sel_text; ?>><?= $index ?> <?= $index == 1 ? lang('form.person') : ($index > 4 && $this->lang->mci_current() == 'me') ? lang('form.person') : lang('form.persons'); ?></option>

                        <?php endfor; ?>

                </select><br>
                <span class = "help-block pull-left">(<?= lang('form.excl'); ?> 0-2)</span>

            </div>

        </div><!--/ persons-->

        <div class = "form-actions">

            <button class = "button-home" type="submit" id="submit"><span><?= lang('form.search'); ?></span></button>

        </div><!--/ actions-->

    </fieldset>

</form>